import axios  from "axios";

//创建一个Axiso实例
const request = axios.create({
    baseURL:'http://localhost:5173'
});

//请求拦截器配置
request.interceptors.request.use(
    (config)=>{
        //从本地存储中获取令牌；
        const token = localStorage.getItem('token');
      
        if(token){
        // 设置请求头的 Authorization 字段为 Bearer 类型的令牌
            config.headers.Authorization = `Bearer ${token}`;
        }
        // 返回经过处理的请求配置对象
        return config;
    }
    
)
//响应拦截器配置
axios.interceptors.response.use(
    function(response) {
        return response;
    },
    (error)=>{

    }
)
export default request;



